<html>
<head><meta charset="utf-8"><title>Infinite loop when using rust-analyzer on rustc · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html">Infinite loop when using rust-analyzer on rustc</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="193360935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/193360935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#193360935">(Apr 08 2020 at 18:36)</a>:</h4>
<p>I'm currently noticing a problem where rust-analyzer stops responding to any queries and pegs a CPU core seemingly forever. This happens regularly when working on a new file I created in the rust compiler under <code>src/librustc_mir/transform/dag_nrvo.rs</code>. I've posted the contents <a href="https://gist.github.com/jonas-schievink/81897788c04417b035a307ce716e6b63" title="https://gist.github.com/jonas-schievink/81897788c04417b035a307ce716e6b63">here</a> but I'm not sure that's enough to reproduce the issue.</p>
<p>Has anybody seen a hang like this before?</p>



<a name="193379541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/193379541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#193379541">(Apr 08 2020 at 21:14)</a>:</h4>
<p>Hmm, I wrote some more code and now the issue seems to be gone</p>



<a name="193379723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/193379723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#193379723">(Apr 08 2020 at 21:16)</a>:</h4>
<p>might be <a href="https://github.com/rust-analyzer/rust-analyzer/issues/3861" title="https://github.com/rust-analyzer/rust-analyzer/issues/3861">https://github.com/rust-analyzer/rust-analyzer/issues/3861</a></p>



<a name="193620791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/193620791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#193620791">(Apr 10 2020 at 21:39)</a>:</h4>
<p>Still seems to be an issue, unfortunately (as of commit 176f7f6)</p>



<a name="193621209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/193621209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#193621209">(Apr 10 2020 at 21:43)</a>:</h4>
<p>Not entirely sure how to reproduce the issue, or how to profile r-a, but running <code>analysis-stats</code> panics with this error:</p>
<blockquote>
<p>thread 'main' panicked at 'no value set for FileTextQuery(FileId(9280))'</p>
</blockquote>
<p>It also outputs a bunch of cyclic dependency errors (that don't seem to cause any issues so far)</p>



<a name="193627449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/193627449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#193627449">(Apr 10 2020 at 22:56)</a>:</h4>
<blockquote>
<p>2958 textDocument/codeAction             132438ms</p>
</blockquote>



<a name="193636162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/193636162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#193636162">(Apr 11 2020 at 01:36)</a>:</h4>
<p>(removed)</p>



<a name="193636168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/193636168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#193636168">(Apr 11 2020 at 01:37)</a>:</h4>
<p>(whoops)</p>



<a name="193652770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/193652770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#193652770">(Apr 11 2020 at 10:06)</a>:</h4>
<p>That analysis-stats panic might be <a href="https://github.com/rust-analyzer/rust-analyzer/issues/3888" title="https://github.com/rust-analyzer/rust-analyzer/issues/3888">https://github.com/rust-analyzer/rust-analyzer/issues/3888</a></p>



<a name="193653296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/193653296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#193653296">(Apr 11 2020 at 10:22)</a>:</h4>
<p>Submitted <a href="https://github.com/rust-analyzer/rust-analyzer/pull/3939" title="https://github.com/rust-analyzer/rust-analyzer/pull/3939">https://github.com/rust-analyzer/rust-analyzer/pull/3939</a> to fix that panic.</p>
<p>However, there is another panic related to Chalk ..</p>



<a name="196832520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/196832520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#196832520">(May 07 2020 at 21:27)</a>:</h4>
<p>I've narrowed this down to the "bad offset" crash that was reported a while ago. I've added a backtrace here: <a href="https://github.com/rust-analyzer/rust-analyzer/issues/4058#issuecomment-625500413" title="https://github.com/rust-analyzer/rust-analyzer/issues/4058#issuecomment-625500413">https://github.com/rust-analyzer/rust-analyzer/issues/4058#issuecomment-625500413</a></p>



<a name="196832745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/196832745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#196832745">(May 07 2020 at 21:29)</a>:</h4>
<p>It looks like r-a is still pegging 6 cores after the crash though, which makes it seem like there's more to this</p>



<a name="196837975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/196837975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#196837975">(May 07 2020 at 22:24)</a>:</h4>
<p>Now it froze the Electron renderer process. This code is just cursed.</p>



<a name="197850265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197850265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197850265">(May 17 2020 at 13:53)</a>:</h4>
<p>The plot thickens...</p>
<div class="codehilite"><pre><span></span><code>    341143ms - add_missing_impl_members_inner
            0ms - Semantics::analyze2 (3 calls)
        10164ms - crate_def_map:wait (82825723 calls)
           10ms - enum_data_query (10 calls)
            0ms - parse_query (1 calls)
        330968ms - ???
</code></pre></div>


<p>5+ minutes for this... is not normal, right?</p>



<a name="197850363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197850363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197850363">(May 17 2020 at 13:54)</a>:</h4>
<p>definitely not</p>



<a name="197851289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197851289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197851289">(May 17 2020 at 14:13)</a>:</h4>
<p>Oh, I was editing in a <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/visit/trait.MutVisitor.html"><code>MutVisitor</code></a> when this happened, that trait has quite a few items (but way fewer than eg. <code>Iterator</code>).</p>



<a name="197851625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197851625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Simon Vandel Sillesen <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197851625">(May 17 2020 at 14:21)</a>:</h4>
<p>(deleted)</p>



<a name="197858017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197858017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197858017">(May 17 2020 at 16:53)</a>:</h4>
<p>Opened <a href="https://github.com/rust-analyzer/rust-analyzer/issues/4498">https://github.com/rust-analyzer/rust-analyzer/issues/4498</a> for further investigation</p>



<a name="197863872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197863872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197863872">(May 17 2020 at 19:00)</a>:</h4>
<p>Any idea why <code>crate_def_map:wait</code> takes over 100ms per invocation? Seems like it really shouldn't, once the def map is computed once.</p>



<a name="197863941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197863941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197863941">(May 17 2020 at 19:03)</a>:</h4>
<p>I think it means either of the two:</p>
<ul>
<li>crate_def_map is waiting on something else for validation (like macro expansion)</li>
<li>verificatio in salsa takes 100ms</li>
</ul>



<a name="197863991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197863991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197863991">(May 17 2020 at 19:04)</a>:</h4>
<p>You mean verification as in checking that the input didn't change?</p>



<a name="197864009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197864009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197864009">(May 17 2020 at 19:05)</a>:</h4>
<p>yup</p>



<a name="197869023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197869023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197869023">(May 17 2020 at 21:08)</a>:</h4>
<p>It looks like <code>find_path</code> is what takes most of the time here</p>



<a name="197870380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197870380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197870380">(May 17 2020 at 21:42)</a>:</h4>
<p>Querifying <code>importable_locations_in_crate</code> brought the entire ordeal down to 20 seconds</p>



<a name="197870382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197870382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197870382">(May 17 2020 at 21:42)</a>:</h4>
<p>Not sure if that's a good approach though</p>



<a name="197872403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872403">(May 17 2020 at 22:33)</a>:</h4>
<p>Hmm, I feel like <code>ra_prof</code> sometimes wrongly attributes time spent somewhere. And here the indentation here looks weird (but the times kinda make sense?):</p>
<div class="codehilite"><pre><span></span><code>    20399ms - add_missing_impl_members_inner
            0ms - Semantics::analyze2 (3 calls)
            0ms - crate_def_map:wait (2038 calls)
            9ms - enum_data_query (10 calls)
        20366ms - find_path (347 calls)
        0ms - Semantics::analyze2 (4 calls)
        6ms - add_missing_impl_members_inner (1 calls)
</code></pre></div>



<a name="197872468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872468">(May 17 2020 at 22:34)</a>:</h4>
<blockquote>
<p>sometimes wrongly attributes time spent somewhere. </p>
</blockquote>
<p>I had this feeling as well, though I haven't dug into it</p>



<a name="197872472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872472">(May 17 2020 at 22:35)</a>:</h4>
<p>The indentation in the example seems ok?</p>



<a name="197872475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872475">(May 17 2020 at 22:35)</a>:</h4>
<p>3 outer functions are on the same level</p>



<a name="197872477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872477">(May 17 2020 at 22:35)</a>:</h4>
<p>nested funcitons are nested</p>



<a name="197872480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872480">(May 17 2020 at 22:35)</a>:</h4>
<p>(<code>-</code>) is the level of indent, not the number</p>



<a name="197872526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872526">(May 17 2020 at 22:36)</a>:</h4>
<p><code>find_path</code> is also used by the auto-import machinery, right? I think I've seen it working surprisingly long, so I bet there's some stupid tihng hidden there</p>



<a name="197872537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872537">(May 17 2020 at 22:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133169">matklad</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc/near/197872480">said</a>:</p>
<blockquote>
<p>(<code>-</code>) is the level of indent, not the number</p>
</blockquote>
<p>Oh, okay. I thought the whitespace in the front was.</p>



<a name="197872539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872539">(May 17 2020 at 22:37)</a>:</h4>
<p>Yeah it is</p>



<a name="197872594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872594">(May 17 2020 at 22:38)</a>:</h4>
<p>yeah, <code>&lt;</code> aligned timings look weird. It looks much better if you don't have 20 seconds outliers</p>



<a name="197872606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872606">(May 17 2020 at 22:39)</a>:</h4>
<p>Wait, are you runing ra_profile with big cutoff?</p>



<a name="197872611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872611">(May 17 2020 at 22:39)</a>:</h4>
<p>Yeah, <code>RA_PROFILE='*&gt;1000'</code></p>



<a name="197872615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872615">(May 17 2020 at 22:39)</a>:</h4>
<p>Ah, that explains why we collapse 347 calls</p>



<a name="197872622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872622">(May 17 2020 at 22:39)</a>:</h4>
<p>I don't understand why 0ms calls are still showing up with that</p>



<a name="197872675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872675">(May 17 2020 at 22:40)</a>:</h4>
<p>we show one-level of 0ms calls, to make sure that everything is printed</p>



<a name="197872684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872684">(May 17 2020 at 22:40)</a>:</h4>
<p>Like, we skip the children, but we show first-level, to make it clear that the profiling acutlaly works</p>



<a name="197872791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872791">(May 17 2020 at 22:42)</a>:</h4>
<p>Ah, okay. So probably I'm just misinterpreting the output and it's measuring correctly.</p>



<a name="197872808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872808">(May 17 2020 at 22:43)</a>:</h4>
<p>Each <code>find_path</code> call still takes around 100ms, and there's a huge number of paths in the default impls, so that explains why it's still slow</p>



<a name="197872854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872854">(May 17 2020 at 22:44)</a>:</h4>
<p>I think many of those are for the same item, maybe some more aggressive caching would help</p>



<a name="197872917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197872917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197872917">(May 17 2020 at 22:46)</a>:</h4>
<div class="codehilite"><pre><span></span><code>              173ms - QualifyPaths::get_substitution_inner
                  173ms - find_path
                       10ms - crate_def_map:wait (32769 calls)
                      122ms - find_importable_locations (16384 calls)
</code></pre></div>



<a name="197873041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197873041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197873041">(May 17 2020 at 22:50)</a>:</h4>
<p>I think there are at least three wrong things here:</p>
<ul>
<li>we do something horribly inefficient. In the trace in the issue, there are 500k calls to some query, and there shouldn't be any 500k of anything. It's not inefficiently, it literarly is quadratic behavior </li>
<li>we can add caching to do efficient stuff less</li>
<li>we actually shouldn't be computing assists edits at all, unless the user applies them</li>
</ul>



<a name="197873317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197873317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197873317">(May 17 2020 at 22:54)</a>:</h4>
<p>One thing that the <code>find_path</code> code does is looking up a name in <em>every</em> module of <em>every</em> dependency, and in the current crate as well. That might explain the high query counts.</p>



<a name="197873841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197873841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197873841">(May 17 2020 at 23:02)</a>:</h4>
<p>Yeah, that probably is bad</p>



<a name="197898918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Infinite%20loop%20when%20using%20rust-analyzer%20on%20rustc/near/197898918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Infinite.20loop.20when.20using.20rust-analyzer.20on.20rustc.html#197898918">(May 18 2020 at 07:29)</a>:</h4>
<p>I originally had a query for this in the <code>find_path</code> PR, we removed it because it wasn't clear it was really necessary <span aria-label="grimacing" class="emoji emoji-1f62c" role="img" title="grimacing">:grimacing:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>